home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 376-400 / disk_393 / ilbmlib / includes / iff.i < prev    next >
Text File  |  1992-05-06  |  14KB  |  487 lines

  1. ;************************************************************************
  2. ; IFF.i  defs for IFF-85 Interchange Format Files - ILBM library.  6/9/89
  3. ;
  4. ; Original C includes by Jerry Morrison and Steve Shaw, Electronic Arts.
  5. ; Assembly include file by Jeff Glatt, dissidents. Some structures have been
  6. ; modified from the original EA code such that they are not compatible.
  7. ; This software is in the public domain.
  8. ;
  9. ; Set your editor's TAB width to 3 chars.
  10. ;************************************************************************
  11.  
  12.  
  13. ;********************* LIB VECTOR OFFSETS (LVO) **************************
  14. _LVOLoadIFFToWindow    equ -30
  15. _LVOLoadILBM            equ -36
  16. _LVOLoadIFF                equ -42
  17. _LVOGetCMAP                equ -48
  18. _LVOGetBODY                equ -54
  19. _LVOUnPackRow            equ -60
  20. _LVOOpenRIFF            equ -66
  21. _LVOOpenRGroup            equ -72
  22. _LVOFileLength            equ -78
  23. _LVOGetPChunkHdr        equ -84
  24. _LVOGetF1ChunkHdr        equ -90
  25. _LVOGetFChunkHdr        equ -96
  26. _LVOGetChunkHdr        equ -102
  27. _LVOSkipFwd                equ -108
  28. _LVOIFFReadBytes        equ -114
  29. _LVOCloseRGroup        equ -120
  30. _LVOHandleCCRT            equ -126
  31. _LVOHandleCRNG            equ -132
  32. _LVOHandleCAMG            equ -138
  33. _LVOCopyILBMProp        equ -144
  34. _LVOSaveWindowToIFF    equ -150
  35. _LVOSaveILBM            equ -156
  36. _LVOIFFWriteBytes        equ -162
  37. _LVOPutBODY                equ -168
  38. _LVOPackRow                equ -174
  39. _LVOPutCMAP                equ -180
  40. _LVOOpenWIFF            equ -186
  41. _LVOOpenWGroup            equ -192
  42. _LVOStartWGroup        equ -198
  43. _LVOPutCkHdr            equ -204
  44. _LVOPutCk                equ -210
  45. _LVOPutCkEnd            equ -216
  46. _LVOEndWGroup            equ -222
  47. _LVOCloseWGroup        equ -228
  48. _LVOInitBMHdr            equ -234
  49. _LVOGetIFFPMsg            equ -240
  50. _LVOSearchPROP            equ -246
  51. _LVOGetPROPStruct        equ -252
  52. _LVOFreePROPStruct    equ -258
  53. _LVOSaveANIM            equ -264
  54. _LVODecodeVKPlane        equ -270
  55. _LVOMakeYTable            equ -276
  56. _LVODecompDLTA            equ -282
  57. _LVOBlankPointer        equ -288
  58. _LVOScaleImage            equ -294
  59. _LVOSetupBitmap        equ -300
  60. _LVODecompBODY            equ -306
  61.  
  62. ;=========================================================================
  63. ;The IFF Group IDs (LIST, FORM, PROP, & CAT) are followed by a subtype ID
  64. ;that identifies what kind of chunks will follow (i.e. ILBM, SMUS, 8SVX...).
  65. ;"FORM type XXXX", "LIST of FORM type XXXX", "PROPerties associated
  66. ;with FORM type XXXX", or "conCATenation of XXXX".
  67. ;
  68. ;ChunkID        dc.b [4 ascii letters]    ;also the Group ID in the master Context
  69. ;ChunkSize    dc.l [number of subsequent data bytes, including subID's 4 bytes]
  70. ;SubID        dc.b [4 ascii letters]
  71. ;
  72. ; Every IFF file should start with the above Group header (for example):
  73. ;ChunkID        dc.b 'FORM'
  74. ;ChunkSize    dc.l [the number of bytes following this LONG]
  75. ;SubID        dc.b 'ILBM'        ;this is an IFF picture then
  76. ;
  77. ;The remaining chunks in the file will be those that are expected for that
  78. ;type of file. (i.e. ILBMs have BMHD, CMAP, CAMG, etc chunks) A chunk
  79. ;consists of a 4 byte ID, a ULONG indicating the number of data bytes in the
  80. ;chunk, and then those data bytes.
  81. ;
  82. ; Pass chunkSize = UNKNOWN to Writer routines to mean "compute the size" after
  83. ; all the data has been written and the context is closed.
  84.  
  85. UNKNOWN equ $80000001
  86.  
  87. ;Address Offsets for a chunk header.
  88. ChunkID        equ    0
  89. ChunkSize    equ    4
  90. ChunkData    equ    8
  91. sizeofChunkHeader    equ    12
  92.  
  93. ;Address Offsets for a group header
  94. GroupID        equ    0
  95. GroupSize    equ    4
  96. SubID            equ    8
  97. GroupData    equ    12
  98. sizeofGroupHeader    equ    16
  99.  
  100. ;This macro rounds up the 32 bit value in a data register to an even number.
  101. WordAlign MACRO
  102.     Bclr.l    #0,\1
  103.     beq.s        _even
  104.     addq.l    #2,\1
  105. _even:
  106.     ENDM
  107.  
  108. ;This macro computes the total "physical size" of a padded chunk from
  109. ;its "data size" or "logical size" which is contained in a data register.
  110. ;  ChunkPSize  d0
  111. ChunkPSize MACRO
  112.     addq.l    #sizeofChunkHeader,\1
  113.     Bclr.l    #0,\1
  114.     beq.s        _Even
  115.     addq.l    #2,\1
  116. _Even:
  117.     ENDM
  118.  
  119. ;Standard group IDs.  A chunk with one of these IDs contains a
  120. ;SubTypeID followed by zero or more chunks.
  121. ID_FORM        equ    'FORM'
  122. ID_PROP        equ    'PROP'
  123. ID_LIST        equ    'LIST'
  124. ID_CAT        equ    'CAT '
  125. ID_FILLER    equ    '    '
  126.  
  127. ;SubTypeIDs
  128. ID_ILBM        equ    'ILBM'
  129. ID_ANIM        equ    'ANIM'
  130.  
  131. ;ILBM Chunk IDs
  132. ID_BMHD    equ    'BMHD'
  133. ID_CMAP    equ    'CMAP'
  134. ID_GRAB    equ    'GRAB'
  135. ID_DEST    equ    'DEST'
  136. ID_SPRT    equ    'SPRT'
  137. ID_CAMG    equ    'CAMG'
  138. ID_BODY    equ    'BODY'
  139. ID_CRNG    equ    'CRNG'
  140. ID_CCRT    equ    'CCRT'
  141.  
  142. ;ANIM Chunk IDs
  143. ID_DLTA    equ    'DLTA'
  144. ID_ANHD    equ    'ANHD'
  145.  
  146. ID_ANFR    equ    'ANFR'
  147. ID_MAHD    equ    'MAHD'
  148. ID_MFHD    equ    'MFHD'
  149. ID_CM16    equ    'CM16'
  150. ID_ATXT    equ    'ATXT'
  151. ID_PTXT    equ    'PTXT'
  152.  
  153. sizeofID    equ    4
  154.  
  155. ;=============IFFP Status code return from the Lib Functions================
  156. ; A LONG returned in d0, because it must be the same size as a 4 byte ascii,
  157. ; chunkID (as returned by GetChunkHdr for example).
  158. ; Note that the error codes below are not legal IFF IDs because they are not
  159. ; standard ascii chars. If a routine ever returns a LONG that is negative,
  160. ; then this constitutes an IFFP error code, not an IFF ID.
  161. ; Always check IFFP error codes (bmi toError). Don't press on after an error!
  162. ; These routines try to have no side effects in the error case, except
  163. ; partial I/O is sometimes unavoidable.
  164.  
  165. IFF_OKAY         equ  0  ;Keep going...(not end of file, but we haven't found
  166.                            ;our requested FORM or an error yet) Note that the
  167.                            ;highest level routines use this to really mean that
  168.                            ;everything went well. (see LoadIFFToWindow)
  169. END_MARK         equ -1  ;Encountered the end of a group (i.e. FORM, LIST, etc).
  170.                            ;The end of the entire file if you are at the top group.
  171. IFF_DONE         equ -2  ;Returns this when it has READ enough.
  172.                      ;It means return thru all levels. File is Okay.
  173. DOS_ERROR     equ -3  ;AmigaDOS Read or Write error.
  174. NOT_IFF         equ -4  ;Not an IFF file.
  175. NO_FILE         equ -5  ;Tried to open file, AmigaDOS didn't find it.
  176. CLIENT_ERROR equ -6  ;Application made invalid request, for instance, write
  177.                            ;a negative size chunk.
  178. BAD_FORM         equ -7  ;A read routine complains about FORM semantics
  179.                            ;e.g. valid IFF file, but missing a required chunk such
  180.                            ;as an ILBM without a BMHD chunk.
  181. SHORT_CHUNK     equ -8  ;Application asked IFFReadBytes to read more bytes than
  182.                            ;left in the chunk. Could be an applic. bug or bad file.
  183. BAD_IFF         equ -9  ;mal-formed IFF file. Found half a chunk? A CAT with a
  184.                            ;PROP in it?
  185. IFF_NOTFOUND equ -10    ;The requested FORM not found within the IFF file
  186.                             ;(Did you try to find an ILBM in an SMUS file?)
  187.  
  188. IFF_NOMEM    equ    -11    ;Out of mem while loading file
  189. UNKNOWN_ERROR    equ -12    ;This error is unknown (i.e. not 1 of the preceding)
  190.                                 ;The library will never return this.
  191.  
  192. ;=================== BitMapHeader (BMHD Chunk) ================== 
  193.  
  194. ;Choice of masking technique
  195. mskNone                        equ    0
  196. mskHasMask                    equ    1
  197. mskHasTransparentColor    equ    2
  198. mskLasso                        equ    3
  199.  
  200. ;Choice of compression algorithm applied to
  201. ;each row of the source and mask planes. "cmpByteRun1" is the byte run
  202. ;encoding generated by Mac's PackBits.
  203. cmpNone        equ    0
  204. cmpByteRun1    equ    1
  205.  
  206. ;Aspect ratios: The proper fraction xAspect/yAspect represents the pixel
  207. ;aspect ratio pixel_width/pixel_height.
  208.  
  209. ;For the 4 Amiga display modes:
  210. ;      320 x 200: 10/11  (these pixels are taller than they are wide)
  211. ;      320 x 400: 20/11
  212. ;      640 x 200:  5/11
  213. ;      640 x 400: 10/11
  214. x320x200Aspect equ 10
  215. y320x200Aspect equ 11
  216. x320x400Aspect equ 20
  217. y320x400Aspect equ 11
  218. x640x200Aspect equ 5
  219. y640x200Aspect equ 11
  220. x640x400Aspect equ 10
  221. y640x400Aspect equ 11
  222.  
  223. ; A BitMapHeader is stored in a BMHD chunk.
  224. ;    dc.w w,h                            ; raster width & height in pixels
  225. ;    dc.w x,y                            ; position for this image
  226. ;    dc.b nPlanes                    ; # source bitplanes
  227. ;    dc.b masking                    ; masking technique
  228. ;    dc.b compress                    ; compression algoithm 
  229. ;    dc.b pad1                        ; UNUSED.  For consistency, put 0 here
  230. ;    dc.w transparentColor        ; transparent "color number"
  231. ;    dc.b xAspect,yAspect            ; aspect ratio, a rational number x/y
  232. ;    dc.w pageWidth,pageHeight    ; source "page" size in pixels
  233.  
  234. BMHD_w            equ    0
  235. BMHD_h            equ    2
  236. BMHD_x            equ    4
  237. BMHD_y            equ    6
  238. BMHD_nPlanes    equ    8
  239. BMHD_masking    equ    9
  240. BMHD_compress    equ    10
  241. BMHD_pad            equ    11
  242. BMHD_color        equ    12
  243. BMHD_xAspect    equ    14
  244. BMHD_yAspect    equ    15
  245. BMHD_pageW        equ    16
  246. BMHD_pageH        equ    18
  247.  
  248. sizeofBMHD        equ    20 ;not counting the header ID and chunkSize
  249.  
  250. ;This macro computes the number of bytes in a row, from the width in pixels.
  251. ; RowBytes d0
  252. RowBytes MACRO
  253.     addi.w    #15,\1
  254.     lsr.w        #3,\1
  255.     Bclr.l    #0,\1
  256.     ENDM
  257.  
  258. ; ==================== ColorRegister ========================== 
  259. ; A CMAP chunk is a packed array of ColorRegisters (3 bytes each).
  260.  
  261. sizeofColorRegister equ 3
  262.  
  263. ;Maximum number of bitplanes in RAM. Current Amiga max w/dual playfield.
  264. MaxAmDepth  equ 6
  265.  
  266. ;Maximum number of color regs in amiga colorTable
  267. maxColorReg equ 32
  268.  
  269. ;This macro is passed the number of colors to save in a data register. It
  270. ;converts that into the number of bytes in the resulting CMAP chunk (not
  271. ;counting the header and any pad byte).
  272. sizeofCMAP MACRO
  273.     mulu.w    #3,\1
  274.     ENDM
  275.  
  276. ; ========================= GRAB ==============================
  277. ; A Point2D is stored in a GRAB chunk.
  278.  
  279. GRAB_x    equ    0
  280. GRAB_y    equ    2
  281.  
  282. sizeofGRAB    equ    4
  283.  
  284. ; ========================= DestMerge ===========================
  285. ; A DestMerge is stored in a DEST chunk.
  286.  
  287. ;    dc.b depth            ; # bitplanes in the original source
  288. ;    dc.b pad1            ; UNUSED, for consistency store 0 here
  289. ;    dc.w planePick    ; how to scatter source bitplanes into destination
  290. ;    dc.w planeOnOff    ; default bitplane data for planePick
  291. ;    dc.w planeMask    ; selects which bitplanes to store into
  292.  
  293. DEST_depth            equ 0
  294. DEST_pad                equ 1
  295. DEST_planePick        equ 2
  296. DEST_planeOnOff    equ 4
  297. DEST_planeMask        equ 6
  298.  
  299. sizeofDEST    equ    8
  300.  
  301. ; =========================== ANHD ==============================
  302.  
  303. ;operation modes
  304. DirectSet        equ 0
  305. _XOR                equ 1
  306. LongDelta        equ 2
  307. ShortDelta        equ 3
  308. ShortLong        equ 4
  309. ByteVertical    equ 5
  310. Juggler            equ 74
  311.  
  312. ;Bits values
  313. ShortData        equ 0
  314. LongData            equ 1
  315. Set                equ 0
  316. _Xor                equ 2
  317. SeparateInfo    equ 0
  318. OneInfoList        equ 4
  319. NotRLC            equ 0
  320. RLC                equ 8
  321. Horizontal        equ 0
  322. Vertical            equ 16
  323. ShortInfo        equ 0
  324. LongInfo            equ 32
  325.  
  326. ;    dc.b operation
  327. ;    dc.b mask
  328. ;    dc.w w,h
  329. ;    dc.w x,y
  330. ;    dc.l abstime
  331. ;    dc.l reltime
  332. ;    dc.b interleave
  333. ;    dc.b AnhdPad0
  334. ;    dc.l bits
  335. ;    ds.b 16
  336.  
  337. ANHD_op            equ    0
  338. ANHD_mask        equ    1
  339. ANHD_w            equ    2
  340. ANHD_h            equ    4
  341. ANHD_x            equ    6
  342. ANHD_y            equ    8
  343. ANHD_abstime    equ    10
  344. ANHD_reltime    equ    14
  345. ANHD_interleave    equ    18
  346. ANHD_pad0        equ    19
  347. ANHD_bits        equ    20
  348. ANHD_pad1        equ    24
  349.  
  350. sizeofANHD        equ    40
  351.  
  352. ;======================= Other Chunks ===========================
  353. ; Commodore Amiga ViewPort->Modes is stored in a CAMG chunk. The
  354. ; chunk's content is declared as a ULONG.
  355.  
  356. sizeofCAMG    equ    4
  357. sizeofSPRT    equ    4
  358.  
  359. ; ======================== CRNG ===============================
  360.  
  361. maxCycles  equ  8        ;the ILBMFrame can hold 8 CRNG chunks
  362. RNG_NORATE equ  36    ;Dpaint uses this rate to mean non-active
  363.  
  364. ;pad1   dc.w  0   ;future use - store 0 here
  365. ;rate   dc.w  0   ;60/sec=16384, 30/sec=8192, 1/sec=16384/60=273
  366. ;active dc.w  0   ;lo bit 0=no cycle, 1=yes; next bit 1=reverse
  367. ;low    dc.b  0   ;range lower
  368. ;high   dc.b  0   ;range upper
  369.  
  370. CRNG_rate    equ    2
  371. CRNG_active    equ    4
  372. CRNG_low        equ    6
  373. CRNG_high    equ    7
  374.  
  375. sizeofCRNG    equ    8
  376.  
  377. ;===================== VECTOR STRUCTURE (16 bytes) ====================
  378. ; When using mid-level load routines, you must allocate and initialize a
  379. ; vector structure. This structure holds the addresses of whatever routines
  380. ; you would like the lib to execute while parsing an IFF file. If the vector
  381. ; address is 0, then the default lib routine is used.
  382. ;
  383. ;PROPhandler        dc.l 0
  384. ;FORMhandler        dc.l 0
  385. ;CHUNKhandler        dc.l 0
  386. ;NonILBMhandler    dc.l 0 
  387.  
  388. PROPhand        equ 0
  389. FORMhand        equ 4
  390. CHUNKhand    equ 8
  391. NONILBMhand    equ 12
  392.  
  393. sizeofVectors    equ    16
  394.  
  395. ;================ ILBMFrame structure (172 bytes) ====================
  396. ;iFlags            dc.b 0    ;flags for whether BMHD, CAMG chunk found
  397. ;iUserFlags        dc.b 0    ;for whether you want no title bar, mouse pointer
  398. ;iBMHD            ds.b 20   ;20 byte IFF BitMap Header chunk (BHMD)
  399. ;iViewModes        dc.l 0    ;CAMG chunk (contains just 1 LONG, ViewModes)
  400. ;iColorTable    ds.w 32   ;a WORD for each color (32 colors MAX)
  401. ;iNumColors        dc.b 0    ;number of colorTable values loaded (32 MAX)
  402. ;iCycleCnt        dc.b 0    ;# of cycles for color cycling (Range = 0 to 7)
  403. ;iCRNG            ds.b 8*8  ;8, 8 Byte CRNG chunks for color cycling
  404. ;iWindow            dc.l 0
  405. ;iScreen            dc.l 0
  406. ;iBMAP            dc.l 0
  407. ;iBmSize            dc.l 0
  408.  
  409. sizeofILBMFrame equ 172
  410.  
  411. iFlags        equ 0
  412. iUserFlags    equ 1
  413. iBMHD            equ 2
  414. iViewModes    equ 22
  415. iColorTable    equ 26
  416. iNumColors    equ 90
  417. iCycleCnt    equ 91
  418. iCRNG            equ 92
  419. iWindow        equ 156
  420. iScreen        equ 160
  421. iBMAP            equ 164
  422. iBmSize        equ 168
  423.  
  424. ;definitions for bits of iFlags field
  425. BMHDFLAG    equ 0 ;set if a BMHD chunk found in the file
  426. CAMGFLAG    equ 1 ;set if a CAMG chunk found
  427. ANHDFLAG equ 2 ;set if an ANHD chunk found. This is for the use of your
  428.                     ;custom CHUNKhandler or PROPhandler.
  429.  
  430. ;bit definitions for iUserFlags. These must be initialized by you.
  431. MOUSEFLAG    equ 0 ;set for no mouse pointer
  432. SCREENFLAG    equ 1 ;set for hide screen title bar
  433. COLORFLAG    equ 2 ;set for "Don't use loaded colorMap. Preserve present map."
  434. NOSCALE        equ 3 ;set for "Don't scale a lower res pic to fill a larger bitmap"
  435. ADJUSTVIEW    equ 4 ;do overscan if larger than standard Intuition view
  436. FORCEPARSE    equ 5 ;ignore IFF_DONE and force parsing to continue to end of file
  437.  
  438. ANIMFLAG        equ 7 ;set if an ANIM file
  439.  
  440. ;===================== A PROPList ============================
  441. ; NextFrame    dc.l [the address of the next frame in list]
  442. ; Entries    dc.w [the number of frames in the list]
  443.  
  444.  
  445. ;================== AN ILBMPropFrame ==============================
  446. ; Since the routines GetPROPStruct and SearchPROP return the data portion
  447. ; (the actual ILBMFrame of the structure), you access the fields using the
  448. ; same offsets as an ILBMFrame. The new, extended fields are at negative
  449. ; offsets to the data portion, and of course, the size is different.
  450. ; The extended fields are as follows:
  451. ;
  452. ;iNext    dc.l 0  ;the Next PropFrame
  453. ;iID        dc.l 0  ;the type of PROP (i.e. 'ILBM')
  454. ;iPFSize    dc.w 0  ;the total size of this structure including this header
  455.  
  456. sizeofILBMProp equ sizeofILBMFrame+10
  457.  
  458. iNext        equ -10
  459. iID        equ -6
  460. iPFSize    equ -2
  461.  
  462. ;========36 byte Context structure (to read/write an IFF Group)===========
  463. ;parentContext    dc.l 0
  464. ;UserData        dc.l 0    ;For application use
  465. ;fileHandle        dc.l 0
  466. ;position        dc.l 0
  467. ;bound            dc.l 0
  468. ;chunkID            dc.b [4 ascii]
  469. ;chunkSize        dc.l 0
  470. ;subID            dc.b [4 ascii]
  471. ;bytesSoFar        dc.l 0
  472.  
  473. ; To compute the number of bytes not yet read from the current chunk, given
  474. ; a context structure, remainingBytes = chunkSize - bytesSoFar
  475.  
  476. conParent        equ 0
  477. conUserData        equ 4
  478. conFile            equ 8
  479. conPosition        equ 12
  480. conBound            equ 16
  481. conChunkID        equ 20
  482. conChunkSize    equ 24
  483. conSubID            equ 28
  484. conSoFar            equ 32
  485.  
  486. sizeofContext    equ 36
  487.